#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__

#include "maajanTile.h"
#include "maajanHand.h"
#include "player.h"
#include "tableProp.h"


class controller {
	private:
		maajanHand hands[];
		maajanTile tiles[];
		player playerList[];
		dice dices[];
		
	public:
	
		virtual ~controller() = 0;
		
	protected:
	
};


class gameControl : public controller {
	private:
		int tilesNumRest;
		maajanTile tilesDiscardedCurrentTurn[];
		int oya;
//		long int timer;
		dice dices[];
		gameLogic logicModule;
		
	public:
		gameControl(maajanHand &h[], maajanTile &t[], player &p[], dice &d[], gameLogic &l);
		
		void startGame();
		void distributeCards(std::deque<int> &distList);

	protected:
		void startRound();
		void turnContinue() // update varibales
		void roundEnd();
		
		action askAction(); // return action ID (defined in marcos.h)
		void meldRequest(player &p, action requestType); // ask other 3 players for actions
		bool handValidation(majaanHand &hand); // will call round end
		
		void updateLog();
		void updateClient(); // tell all clients to update
		
};


class gameLogic : public contorller {
	private;
	
	public:
		gameLogic(maajanHand &h[], maajanTile &t[], player &p[], dice &d[]);
	
		int seatDetermination(); // 4-digit seat arrangement
		std::deque<int> getCardInitialDistribute(); // list of index
		int tensuCalculator(const int &index); // index - index of player
		
		int requestConflictProcessor(int req); // 4-digit req arrangement
		
		
};


class gameLog : public controller {
	private:
		string filename;
		actionPairs pairs;
		int index;
		
	public:
		gameLog(maajanHand &h[], maajanTile &t[], player &p[], dice &d[], string &fn, actionPairs &p);
		
		actionPairs getactionPairs(); // add new action
		void writeLog(); // record all actions to file
		
		~gameLog();
		
};


#endif	